using FastNet.Core.Enums;

namespace FastNet.Core.Utilities;
#nullable disable
public class ResponseContent
{
    public ResponseContent()
    {
    }
    public ResponseContent(bool status)
    {
        this.Status = status;
    }
    public bool Status { get; set; }
    public string Code { get; set; }
    public string Message { get; set; }
    public object Data { get; set; }

    public ResponseContent OK()
    {
        this.Status = true;
        return this;
    }

    public static ResponseContent Instance
    {
        get { return new ResponseContent(); }
    }
    public ResponseContent OK(string message = null,object data=null)
    {
        this.Status = true;
        this.Message = message;
        this.Data = data;
        return this;
    }
    public ResponseContent OK(ResponseCode responseType)
    {
        return Set(responseType, true);
    }
    public ResponseContent Error(string message = null)
    {
        this.Status = false;
        this.Message = message;
        return this;
    }
    public ResponseContent Error(ResponseCode responseType)
    {
        return Set(responseType, false);
    }
    public ResponseContent Set(ResponseCode responseType)
    {
        bool? b = null;
        return this.Set(responseType, b);
    }
    public ResponseContent Set(ResponseCode responseType, bool? status)
    {
        return this.Set(responseType, null, status);
    }
    public ResponseContent Set(ResponseCode responseType, string msg)
    {
        bool? b = null;
        return this.Set(responseType, msg, b);
    }
    public ResponseContent Set(ResponseCode responseType, string msg, bool? status)
    {
        if (status != null)
        {
            this.Status = (bool)status;
        }
        this.Code = ((int)responseType).ToString();
        if (!string.IsNullOrEmpty(msg))
        {
            Message = msg;
            return this;
        }
        Message = responseType.GetDescription();
        return this;
    }
}
